// SQL Select builder datapump definition
// Copyright 2006 (C) Ralph Thomas

#ifndef MISSION_DATAPUMPS_SQL_SELECT_H
#define MISSION_DATAPUMPS_SQL_SELECT_H

#include <adobe/value.hpp>
#include <adobe/dictionary.hpp>
#include <adobe/adam.hpp>

namespace datapumps {
	//
	/// The sql_select datapump builds an SQL SELECT query based on the
	/// parameters it's given. It's main advantage over using string
	/// substitution is that it correctly handles expanding arrays into
	/// where-clauses and always escapes strings.
	///
	/// The arguments it takes are:
	/// <ul>
	///  <li>"columns" -- the columns to select from the table, an array.</li>
	///  <li>"where" -- a dictionary containing the column name and acceptable
	///      values as the kv-pairs. The values may be datapumps, and the
	///      dictionary itself may come from a datapump.</li>
	///  <li>"table" -- the table(s) to select from, a string or array</li>
	///  <li>"order" -- how to order the results, a string or array</li>
	/// </ul>
	///
	/// @param	params	the parameters in a dictionary.
	/// @param	sheet	the sheet to resolve @names into.
	//
	adobe::value_t make_sql_select_datapump( const adobe::dictionary_t& params, adobe::sheet_t& sheet );
	//
	/// The make_sql_column function should be registered in the virtual machine.
	/// It allows one to reference a column name in the "where" dictionary.
	///
	/// \param	name	the name of the column (always a string).
	/// \return	a type that it recognized by the sql_select datapump.
	//
	adobe::value_t make_sql_column( const adobe::array_t& column );
}

#endif

